package cn.huiyunche.base.service.vo;

import cn.huiyunche.base.service.enums.YeepayFeeTypeEnum;
import cn.huiyunche.base.service.enums.YeepayUrgencyEnum;
import org.jdom.Document;
import org.jdom.Element;

/**
 * 易宝请求xml实体
 *
 * @author hdy [Tuffy]
 */
public class YeepayXmlRequestVo {

    private Document xml = new Document(); // 根
    private Element cmd = new Element("cmd"); // 命令 单笔代付
    private Element groupId = new Element("group_Id"); // 总公司商户 编号 group_Id
    private Element merId = new Element("mer_Id"); // 实际发起付 款的交易商 户编号 mer_Id
    private Element batchNo = new Element("batch_No"); // 打款批次号 batch_No
    private Element orderId = new Element("order_Id"); // 订单号 order_Id
    private Element bankCode = new Element("bank_Code"); // 银行卡缩写
    private Element amount = new Element("amount"); // 金额 amount
    private Element accountName = new Element("account_Name"); // 帐户名称 account_Name
    private Element accountNumber = new Element("account_Number"); // 帐户号 account_Number
    private Element urgency = new Element("urgency"); // 是否加急
    private Element feeType = new Element("fee_Type"); // 手续费收取 方式
    private Element hmac = new Element("hmac"); // 签名

    public YeepayXmlRequestVo() {
    }

    public YeepayXmlRequestVo(String cmd, String groupId, String merId,
                              String batchNo, String orderId, String bankCode, String amount, String accountName,
                              String accountNumber, String urgency, String hmac) {
        this.cmd.setText(cmd);
        this.groupId.setText(groupId);
        this.merId.setText(merId);
        this.batchNo.setText(batchNo);
        this.orderId.setText(orderId);
        this.bankCode.setText(bankCode);
        this.amount.setText(amount);
        this.accountName.setText(accountName);
        this.accountNumber.setText(accountNumber);
        this.urgency.setText(urgency);
        this.feeType.setText(YeepayFeeTypeEnum.TARGET.getValue());
        /*if (urgency.equals(YeepayUrgencyEnum.Y.getValue())) {
			this.feeType.setText(YeepayFeeTypeEnum.TARGET.getValue());
		} else {
			this.feeType.setText(YeepayFeeTypeEnum.SOURCE.getValue());
		}*/
        this.hmac.setText(hmac);
    }

    public Document getXml() {
        Element data = new Element("data");
        data.addContent(cmd);
        data.addContent(groupId);
        data.addContent(merId);
        data.addContent(batchNo);
        data.addContent(orderId);
        data.addContent(bankCode);
        data.addContent(amount);
        data.addContent(accountName);
        data.addContent(accountNumber);
        data.addContent(urgency);
        data.addContent(feeType);
        data.addContent(hmac);
        xml.addContent(data);
        return xml;
    }

    public void setCmd(String cmd) {
        this.cmd.setText(cmd);
    }

    public String getCmd() {
        return cmd.getText();
    }

    public void setGroupId(String groupId) {
        this.groupId.setText(groupId);
    }

    public String getGroupId() {
        return groupId.getText();
    }

    public void setMerId(String merId) {
        this.merId.setText(merId);
    }

    public String getMerId() {
        return merId.getText();
    }

    public void setBatchNo(String batchNo) {
        this.batchNo.setText(batchNo);
    }

    public String getBatchNo() {
        return batchNo.getText();
    }

    public void setOrderId(String orderId) {
        this.orderId.setText(orderId);
    }

    public String getOrderId() {
        return orderId.getText();
    }


    public String getBankCode() {
        return bankCode.getText();
    }

    public void setBankCode(String bankCode) {
        this.bankCode.setText(bankCode);
    }

    public void setAmount(String amount) {
        this.amount.setText(amount);
    }

    public String getAmount() {
        return amount.getText();
    }

    public void setAccountName(String accountName) {
        this.accountName.setText(accountName);
    }

    public String getAccountName() {
        return accountName.getText();
    }

    public void setAccountNumber(String accountNumber) {
        this.accountNumber.setText(accountNumber);
    }

    public String getAccountNumber() {
        return accountNumber.getText();
    }

    public void setUrgency(String urgency) {
        this.urgency.setText(urgency);
        if (urgency.equals(YeepayUrgencyEnum.Y.getValue())) {
            this.feeType.setText(YeepayFeeTypeEnum.TARGET.getValue());
        } else {
            this.feeType.setText(YeepayFeeTypeEnum.SOURCE.getValue());
        }
    }

    public String getUrgency() {
        return urgency.getText();
    }

    public String getFeeType() {
        return feeType.getText();
    }

    public void setHmac(String hmac) {
        this.hmac.setText(hmac);
    }

    public String getHmac() {
        return hmac.getText();
    }

}
